<template>
	<view class="shopdetail">
		<view class="dishide" v-if="type==2 || shopdata.shop_status!=1"></view>
		
		<shopdetailHeader :shopheaderdata="shopdata" :status="status"></shopdetailHeader>
		<!-- 外卖门店详情 -->
		<shopdetailCom1 :suid="shopid" @editdataFun="editdataFun" v-if="type==1"></shopdetailCom1>
		<!-- 公海门店详情 -->
		<shopdetailCom2 :suid="shopid" @editdataFun="editdataFun" v-else-if="type==2"></shopdetailCom2>
		<!-- 我的门店详情 -->
		<shopdetailCom0 :suid="shopid" @editdataFun="editdataFun" v-else></shopdetailCom0>
		
		
		<!-- 外卖门店详情 -->
		<!-- <shopdetailCom1 :suid="shopid" @editdataFun="editdataFun" v-if="type==1&&status!=1"></shopdetailCom1> -->
		<!-- 公海门店详情 -->
		<!-- <shopdetailCom2 :suid="shopid" @editdataFun="editdataFun" v-else-if="type==2"></shopdetailCom2> -->
		<!-- 我的门店、外卖门店待处理状态详情 -->
		<!-- <shopdetailCom3 :suid="shopid" @editdataFun="editdataFun" v-else-if="(type==0 || type==1)&&status==1"></shopdetailCom3> -->
		<!-- 我的门店详情 -->
		<!-- <shopdetailCom0 :suid="shopid" @editdataFun="editdataFun" v-else></shopdetailCom0> -->
	</view>
</template>

<script>
	import { shopdetail,shopdetailbase } from '../../api/index.js'
	import shopdetailHeader from '../../components/workbench/shopdetail/shopdetailHeader.vue'
	import shopdetailCom0 from '../../components/workbench/shopdetail/shopdetailCom0.vue'
	import shopdetailCom1 from '../../components/workbench/shopdetail/shopdetailCom1.vue'
	import shopdetailCom2 from '../../components/workbench/shopdetail/shopdetailCom2.vue'
	import shopdetailCom3 from '../../components/workbench/shopdetail/shopdetailCom3.vue'
	export default {
		data() {
			return {
				urlData:'',//存储跳转传过来的数据
				isEdit:false,//判断有没有跳转到编辑页面
				status:0,
				shopindex:0,
				shopdata:{},
				shopdetailbasedata:{},
				shopid:'',
				type:0,  //我的0、外卖1、公海门店2
				editdata:{
					id:'',//门店id
					// provinces:'',//省市区
					shop_name:'',//门店名称
					phone:'',//商户服务号码
					sub_shop_name:'',//门店副标题
					address:'',//门店详细地址
					latitude:'',//经度lat
					longitude:''//纬度lng
				}
			}
		},
		onLoad(data) {
			console.log(data)
			this.urlData = data;
			this.getshopdetail(data.suid);
			this.shopid = data.suid;
			this.type = data.type;
			this.status = data.status;
		},
		onShow() {
			if(this.isEdit === true){
				this.getshopdetail(this.urlData.suid);
				this.isEdit = false;
			}
		},
		methods: {
			async getshopdetail(suid){
				let that = this;
				try{
					let data = await shopdetail({id:suid});
					that.shopdata = data.data;
					
					that.editdata.id = that.shopdata.id;
					that.editdata.shop_name = that.shopdata.shop_name;
					that.editdata.sub_shop_name = that.shopdata.sub_shop_name;
					console.log(that.shopdata)
				}catch(e){
					//TODO handle the exception
					console.log(e)
				}
			},
			shopswFun:function(index){
				if(index==3){
					uni.showToast({
						icon:'none',
						title:'该功能正在开发中'
					})
					return ;
				}
				this.shopindex = index;
			},
			//设置编辑按钮带过去的参数
			editdataFun:function(data){
				console.log(data)
				this.editdata.phone = data.phone;
				this.editdata.address = data.address;
				this.editdata.latitude = data.latitude;
				this.editdata.longitude = data.longitude;
			}
		},
		onNavigationBarButtonTap() {
			console.log(this.editdata)
			var editdata = this.editdata;
			if(!editdata.id){
				return ;
			}
			this.isEdit = true;
			uni.navigateTo({
				url: '../editshopinfo/editshopinfo?editdata='+JSON.stringify(editdata)
			});
		},
		components:{
			shopdetailHeader,
			shopdetailCom0,
			shopdetailCom1,
			shopdetailCom2,
			shopdetailCom3
		}
	}
</script>
<style lang="scss" scoped>
	page{
		background-color: #F5F5F5;
	}
	.dishide{
		position: fixed;
		background-color: rgb(0, 122, 255);
		width: 80rpx;
		height: 50rpx;
		z-index: 999;
		top: 20rpx;
		right: 20rpx;
	}
</style>
